package Array;

import java.util.HashMap;
import java.util.Map;

public class lc26 {
    public int removeDuplicates(int[] nums) {
         Map<Integer, Integer> map = new HashMap<>();
         int fast = 0;
         int slow = 0;
         while (fast < nums.length) {
            if (map.containsKey(nums[fast])) {
                fast += 1;
            } else {
                map.put(nums[fast], 1);
                nums[slow] = nums[fast];
                slow += 1;
            }
         }
         return slow;
    }
}